#ifndef AV_LOGIC_MANAGER
#define AV_LOGIC_MANAGER

#include "decode_handler.h"
#include "encode_handler.h"
#include "demux_handler.h"
#include "mux_handler.h"
#include <memory>
// 1. ffmpeg持续生成yuv420p，然后编码在推流
// 2. 打开mp4文件，解封装、解码、假装在渲染
// 3. ffmpeg持续生成yuv420p，然后编码、封装成mp4文件
// 4. 打开mp4文件，解封装、封装，模拟录制场景
namespace lcf
{
    class AVLogicManager
    {
    public:
        static AVLogicManager &GetInstance()
        {
            static AVLogicManager avLogic_;
            return avLogic_;
        }
        bool Start();
        bool Stop();
        bool RenderTask();
        bool RecordTask();

    private:
        AVLogicManager() : demuxer_(std::make_shared<DemuxHandler>()),
                           muxer_(std::make_shared<MuxHandler>()),
                           decoder_(std::make_shared<DecodeHandler>()),
                           encoder_(std::make_shared<EncodeHandler>()),
                           isInit_(false)
        {
        }
        ~AVLogicManager() noexcept {}
        AVLogicManager(const AVLogicManager &other) = delete;
        AVLogicManager &operator=(const AVLogicManager &other) = delete;

    private:
        std::shared_ptr<DecodeHandler> decoder_;
        std::shared_ptr<EncodeHandler> encoder_;
        std::shared_ptr<DemuxHandler> demuxer_;
        std::shared_ptr<MuxHandler> muxer_;
        std::mutex mtx_;
        bool isInit_;
    };
}

#endif